/*
自己选择的路 ,跪着也要走完。朋友们 , 虽然这个世界日益浮躁起来,只
要能够为了当时纯粹的梦想和感动坚持努力下去 , 不管其它人怎么样,我
们也能够保持自己的本色走下去。
To the world , you will be a person , but to a person , you
will be the world .                               ——AKPower
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const ll maxn = 2e5 + 1000;
struct node
{
    ll next_s[26];
    ll cnt;
} tire[maxn];
ll n;
ll tot;
ll index_s[maxn];
string s[maxn];
//创建字典
void insert(ll id)
{
    ll len = s[id].length();
    ll p = 0;
    for (ll i = 0; i < len; i++)
    {
        ll key = s[id][i] - 'a';
        if (tire[p].next_s[key] == 0)
        {
            tire[p].next_s[key] = ++tot;
            tire[tot].cnt = 0;
        }
        p = tire[p].next_s[key];
        tire[p].cnt++; //此节点出现次数加一，统计此前缀个数
    }
    index_s[id] = p; //记录每个字符串对应的结尾节点编号
    return;
}

int main()
{
    IOS;
    cin >> n;
    tire[0].cnt = 0;
    for (ll i = 0; i < 26; i++)
        tire[0].next_s[i] = 0;
    for (ll i = 1; i <= n; i++)
    {
        cin >> s[i];
        reverse(s[i].begin(), s[i].end()); //反转字符串
        insert(i);
    }
    for (ll i = 1; i <= n; i++)
    {
        //输出对应字符串对应叶子节点出现的次数
        cout << tire[index_s[i]].cnt << endl;
    }
    getchar();
    getchar();
    return 0;
}